package com.bungarus.model;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * Created by tang on 2018/12/2.
 */
public class Member implements PageItem{
    //unique id
    private long _id;
    //name in the system
//    private AccountName accountName;
    private String accountName;
    //real name
    private String name;
    //password
    @JsonIgnore
    private String password;
    //tenant id
    private long tenantId;

    public static Builder newBuilder() {
        return new Builder();
    }

    public static class Builder {
        private Member member = new Member();

        public Builder id(long id) {
            member.set_id(id);
            return this;
        }

        public Builder name(String name) {
            member.setName(name);
            return this;
        }

        public Builder account(String account) {
            member.setAccountName(account);
            return this;
        }

        public Builder tenantId(long tenantId) {
            member.setTenantId(tenantId);
            return this;
        }

        public Builder pwd(String pwd) {
            member.setPassword(pwd);
            return this;
        }

        public Member build() {
            return member;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Member)) return false;

        Member member = (Member) o;

        return get_id() == member.get_id();

    }

    @Override
    public int hashCode() {
        return (int) (get_id() ^ (get_id() >>> 32));
    }

    public long get_id() {
        return _id;
    }

    public void set_id(long _id) {
        this._id = _id;
    }

//    public AccountName getAccountName() {
//        return accountName;
//    }
//
//    public void setAccountName(AccountName accountName) {
//        this.accountName = accountName;
//    }

    public String getAccountName() {
        return accountName;
    }

    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public long getTenantId() {
        return tenantId;
    }

    public void setTenantId(long tenantId) {
        this.tenantId = tenantId;
    }

}
